package edu.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * mvc 配置
 *
 * @date 10:58
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Value("${fast.upload.path}")
    private String uploadPath;

    /**
     * 拦截器
     * 不需要了
     * 使用 springsecurity
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {


    }


    /**
     * 静态资源配置
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + uploadPath + "upload/");
    }
}
